Class sjl.ReverseRandomIterator
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sjl.ReverseRandomIterator

java.lang.Object
   |
   +----sjl.Iter
           |
           +----sjl.ReverseRandomIterator

public class ReverseRandomIterator
extends Iter
implements RandomIterator
ReverseRandomIterator is an iterator adapter that will traverse the container in the reverse order of an ordinary RandomlIterator.
    RandomIterator iter = new ReverseRandomIterator(coll.end());
    for (; i.cmp(coll.begin()); i.next()) { ... }
The same functionallity can be found with.
    for (RandomIterator iter = coll.rend(); i.cmp(coll.rbegin()); i.next()) { ... }
Any RandomIterator "iter" can be turned into a reverse iterator with:
    Random reverse_iter = Iter.reverse(iter);
XXX: not true.

Copyright © 1996 Finn Bock


Constructor Index

 o ReverseRandomIterator(RandomIterator)
Construct a new ReverseRandomIterator for the argument iterator.

Method Index

 o cmp(Iterator)
Compares two iterators.
 o distance(Iterator)
Returns the distance from this to the argument iterator.
 o genericCopy()
Create a copy of this.
 o get()
Return the value pointed to by the iterator.
 o get(int)
Return the value pointed to by the iterator.
 o less(Iterator)
Compares two iterators for reletive order
 o next()
Advance the iterator to the next element.
 o next(int)
Advance the iterator to the next element.
 o prev()
Advance the iterator to the previous element.
 o prev(int)
Advance the iterator to the previous element.
 o put(int, Object)
Places a new element in the position pointed to by the iterator.
 o put(Object)
Places a new element in the position pointed to by the iterator.
 o setTo(Iterator)
Assign this iterator to another iterator.

Constructors

 o ReverseRandomIterator
  public ReverseRandomIterator(RandomIterator iter)
Construct a new ReverseRandomIterator for the argument iterator. The newly constructed iterator will have a reference to the argument iterator. Eqch time next() and prev() is called on the ReverseRandomIterator the argument iterator is moved back and forward.
Parameters:
iter - A RandomIterator.

Methods

 o genericCopy
  public Iterator genericCopy()
Create a copy of this. The copy can be moved without affcection this.
Returns:
A new iterator pointing the same element as this.
 o setTo
  public void setTo(Iterator i)
Assign this iterator to another iterator. This is faster than creating a new ReverseRandomIterator object.
 o next
  public Iterator next()
Advance the iterator to the next element. Calls prev() on the actual iterator.
 o prev
  public Iterator prev()
Advance the iterator to the previous element. Calls next() on the actual iterator.
 o next
  public RandomIterator next(int n)
Advance the iterator to the next element. Calls prev(n) on the actual iterator.
 o prev
  public RandomIterator prev(int n)
Advance the iterator to the previous element. Calls next(n) on the actual iterator.
 o get
  public Object get()
Return the value pointed to by the iterator.
 o get
  public Object get(int n)
Return the value pointed to by the iterator.
 o put
  public Object put(Object o)
Places a new element in the position pointed to by the iterator.
 o put
  public Object put(int n,
                    Object o)
Places a new element in the position pointed to by the iterator.
 o cmp
  public boolean cmp(Iterator i)
Compares two iterators.
Returns:
true if the iterators point to the same position.
 o less
  public boolean less(Iterator i)
Compares two iterators for reletive order
Returns:
true if this iterator is reachable from the argument iterator.
 o distance
  public int distance(Iterator i)
Returns the distance from this to the argument iterator.

All Packages  Class Hierarchy  This Package  Previous  Next  Index